'use strict';
module.exports = {
	/**
	 * 此函数名称
	 * @url user/pub/test1 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, config, pubFun, vk, db, _ } = util;
		let { pageIndex = 1, pageSize = 10, uid } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		// 可写与数据库的交互逻辑等等
		let whereJson = {};
		//场景
		switch (data.scene) {
			case 's1':
				whereJson["status"] = 2
				break;
			case 's2':
				whereJson["status"] = 1
				break;
			case 's3':
				whereJson["status"] = -1
				break;
		}
		whereJson['user_id'] = uid

		res = await vk.baseDao.selects({
			dbName: "uni-id-base-order",
			whereJson: whereJson,
			pageIndex: pageIndex,
			pageSize: pageSize,
			foreignDB: [{
				dbName: "order_goods",
				localKey: "_id",
				foreignKey: "oid",
				as: "courseInfo",
				limit: 1,
			}],
			sortArr: [{ "name": "status", "type": "asc" }, { "name": "_add_time", "type": "desc" }]
		});

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
